// +----------------------------------------------------------------------
// | FileName:   ${file_name}  
// +----------------------------------------------------------------------
// | CreateTime: 15/10/19  @下午10:06
// +----------------------------------------------------------------------
// | Author:     xab(admin@xueyong.net.cn)
// +----------------------------------------------------------------------
// | Description:
// +----------------------------------------------------------------------
package cn.xabad.commons.tools;

/**
 * Create By Xueyong
 */
public abstract class CommLog {


    public void info(String TAG, Object str) {
        info(TAG, str, null, true);
    }

    protected void info(String TAG, Object str, String className, boolean customClass) {
        if (customClass)
            className = getMethodNames(Thread.currentThread().getStackTrace());
        android.util.Log.i(TAG, createLog(className, String.valueOf(str)));
        saveLog(createLog(className, String.valueOf(str)));
    }

    public void debug(String TAG, Object str) {
        debug(TAG, str, null, true);
    }

    protected void debug(String TAG, Object str, String className, boolean customClass) {
        if (customClass)
            className = getMethodNames(Thread.currentThread().getStackTrace());
        android.util.Log.d(TAG, createLog(className, String.valueOf(str)));
        saveLog(createLog(className, String.valueOf(str)));
    }

    public void error(String TAG, Object str) {
        error(TAG, str, null, true);
    }

    protected void error(String TAG, Object str, String className, boolean customClass) {
        if (customClass)
            className = getMethodNames(Thread.currentThread().getStackTrace());
        android.util.Log.e(TAG, createLog(className, String.valueOf(str)));
        saveLog(createLog(className, String.valueOf(str)));
    }

    private void saveLog(String paramString) {

    }

    private String createLog(String className, String log) {
        return "[ " + className + " ] " + log;
    }

    protected abstract String getMethodNames(StackTraceElement[] sElements);

}

